using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Practices.Unity;
using UnityContrib.CanonicalObjectExtension;

namespace UnityContrib.CanonicalObjectExtension.Tests
{
    /// <summary>
    /// CanonicalObject Fixture
    /// </summary>
    [TestClass]
    public class CanonicalObjectFixture
    {
        public CanonicalObjectFixture()
        {
        }

        [TestMethod]
        public void CanRegisterePartialTypeForCanonicalObject()   
        {
            IUnityContainer container = new UnityContainer();
            container
                .RegisterType<IBillingCustomer, BillingCustomer>()
                .RegisterType<ICRMCustomer, CRMCustomer>()
                .AddNewExtension<CanonicalObject>()
                .Configure<CanonicalObject>()
                    .RegisterPartialType<IBillingCustomer, BillingCustomer>("CustomerView")
                    .RegisterPartialType<ICRMCustomer, CRMCustomer>("CustomerView");

      
        }
        [TestMethod]
        public void CanResolvePartialType()
        {
            IUnityContainer container = new UnityContainer();
            container
                .RegisterType<IBillingCustomer,BillingCustomer>()
                .RegisterType<ICRMCustomer,CRMCustomer>()
                .AddNewExtension<CanonicalObject>()
                .Configure<CanonicalObject>()
                    .RegisterPartialType<IBillingCustomer, BillingCustomer>("CustomerView")
                    .RegisterPartialType<ICRMCustomer, CRMCustomer>("CustomerView");

            IBillingCustomer partBilling = container.Resolve<IBillingCustomer>();
            ICRMCustomer partCRM = container.Resolve<ICRMCustomer>();

            Assert.IsNotNull(partBilling);
            Assert.IsNotNull(partCRM);
        }
    }
}
